home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
manchester
/
2.2
/
View-examples.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
4KB
|
138 lines
" NAME View-examples
AUTHOR tph@cs.man.ac.uk
FUNCTION tutorial examples of windows & viewports
ST-VERSIONS 2.2
PREREQUISITES
CONFLICTS
DISTRIBUTION world
VERSION 1.1
DATE 22 Jan 1989
SUMMARY View-examples
contains five examples of using windows and viewports
when constructing views with multiple subviews.(2.2).TPH
"!
'From Smalltalk-80, version 2, of April 1, 1983 on 25 May 1987 at 7:32:37 pm'!
!View class methodsFor: 'examples'!
example1
"Create, display and release a single view. The size and
position are given by aRect."
"View example1."
| aRect topView |
aRect _ Rectangle origin: 100@100 extent: 200@150.
topView _ self new.
topView insideColor: Form veryLightGray.
topView borderColor: Form black.
topView borderWidth: 2.
topView window: aRect.
Transcript cr; cr; show: 'topView window: ', topView window printString.
Transcript cr; show: 'topView viewport ', topView viewport printString.
topView display.
topView release.!
example2
"Create, display and release a view with a single subview.
Size and position are given by aRect, from the user."
"View example2."
| aRect topView subView |
aRect _ Rectangle fromUser.
topView _ self new.
topView insideColor: Form veryLightGray.
topView borderColor: Form black.
topView borderWidth: 2.
topView window: aRect.
Transcript cr; cr; show: 'topView window: ', topView window printString.
Transcript cr; show: 'topView viewport ', topView viewport printString.
subView _ self new.
subView insideColor: Form white.
subView borderColor: Form darkGray.
subView borderWidth: 4.
subView window: (topView viewport insetBy: 9@12).
Transcript cr; cr; show: 'subView window: ', subView window printString.
Transcript cr; show: 'subView viewport: ', subView viewport printString.
topView addSubView: subView.
topView display.
topView release.!
example3
"Create, display and release a view with a single subview.
Size and position are given by aRect, from the user. The subView's
window is set to be different from screen co-ordinates."
"View example3."
| aRect topView subView |
aRect _ Rectangle fromUserAspectRatio: 4@3.
topView _ self new.
topView insideColor: Form veryLightGray.
topView borderColor: Form black.
topView borderWidth: 2.
topView window: aRect.
Transcript cr; cr; show: 'topView window: ', topView window printString.
Transcript cr; show: 'topView viewport ', topView viewport printString.
subView _ self new.
subView insideColor: Form white.
subView borderColor: Form darkGray.
subView borderWidth: 4.
topView
addSubView: subView
window: (10@10 extent: 15@15)
viewport: (topView viewport insetBy: 9@12).
Transcript cr; cr; show: 'subView window: ', subView window printString.
Transcript cr; show: 'subView viewport: ', subView viewport printString.
topView display.
topView release.!
example4
"Create, display and release a view with a single subview; this
subView also has a single subView. Size and position for the topView
are given by aRect, from the user. The first subView's window is set
to be different from screen co-ordinates and the second subView uses this
coordinate system to determine it's position within the first subView."
"View example4."
| aRect topView subView subView2 |
aRect _ Rectangle fromUserAspectRatio: 4@3.
topView _ self new.
topView insideColor: Form veryLightGray.
topView borderColor: Form black.
topView borderWidth: 2.
topView window: aRect.
Transcript cr; cr; show: 'topView window: ', topView window printString.
Transcript cr; show: 'topView viewport ', topView viewport printString.
subView _ self new.
subView insideColor: Form white.
subView borderColor: Form darkGray.
subView borderWidth: 4.
topView
addSubView: subView
window: (10@10 extent: 15@15)
viewport: (topView viewport insetBy: 9@12).
Transcript cr; cr; show: 'subView window: ', subView window printString.
Transcript cr; show: 'subView viewport: ', subView viewport printString.
subView2 _ self new.
subView2 insideColor: Form gray.
subView2 borderColor: Form black.
subView2 borderWidth: 2.
subView
addSubView: subView2
window: (0@0 extent: 100@120)
viewport: (subView window insetBy: (3@1 extent: 1@1)).
Transcript cr; cr; show: 'subView2 window: ', subView2 window printString.
Transcript cr; show: 'subView2 viewport: ', subView2 viewport printString.
topView display.
topView release.! !